<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css" />
<script type="text/javascript" src="layui/layui.js"></script>
</head>
<body>
	<form class="layui-form" onsubmit="false" action="">
		<div class="layui-form-item" style="margin-top: 20px">
			<label class="layui-form-label"><span style="color: red;">*</span>用户ID：</label>
			<div class="layui-input-inline" style="width: 350px">
				<input type="text" name="Uid" id="Uid" required
					lay-verify="required" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
		<label class="layui-form-label"><span style="color: red;">*</span>昵称：</label>
			<div class="layui-input-inline" style="width: 350px">
				<input type="text" name="Cname" id="Cname" required
					lay-verify="required" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>评论内容：</label>
			<div class="layui-input-inline" style="width: 350px">
				<input type="text" name="Ccontent" id="Ccontent" required
					lay-verify="required" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>是否匿名:</label>
			<div class="layui-input-inline" style="width: 350px;">
					<input type="radio" name="Canonymity" value="是" title="是" checked> <input
						type="radio" name="Canonymity" value="否" title="否">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-btn-container" style="text-align: center;">
				<button class="layui-btn" lay-submit lay-filter="formDemo">添加</button>
			</div>
		</div>
	</form>

	<script>
		//Demo
		layui.use('form', function() {
			var form = layui.form;
			var $ = layui.jquery;
			//监听提交
			form.on('submit(formDemo)', function(data) {
				var d = data.field;//表单中的数据，定义一个对象来接收
				var url = '/shoppingsix/comments_add';
				$.post(url, d, function(data) {
					if (data.count > 0) {
						var index = parent.layer.getFrameIndex(window.name);//获取当前窗口的name
						parent.layer.close(index);//关闭窗口
					}
				}, "json");
				return false;
			});
		});
	</script>

</body>
</html>